package com.smartao.core.mvc;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * Struts2 Action的抽象基类.
 * @param <T> Action所管理的对象类型.
 */
public abstract class BaseAction extends ActionSupport {

	private static final long serialVersionUID = -617210901847974263L;
	protected Logger logger = LoggerFactory.getLogger(getClass());

	public static final String RELOAD = "reload";
	public static final String VIEW = "view";
	public static final String EDIT = "edit";
	public static final String SAVE = "save";
	public static final String DELETE = "delete";
	public static final String JSON = "json";
	
	protected Long id;
	
	/**分页参数*/
	protected int pageNumber;
	protected int pageSize;
	
	protected ActionContext context = ActionContext.getContext();  
	protected HttpServletRequest request = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST);  
	protected HttpServletResponse response = (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE);  
	protected Map<String, Object> session = context.getSession();  
	
	protected ResultStatus resultStatus;
	
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public ResultStatus getResultStatus() {
		return resultStatus;
	}

	public void setResultStatus(ResultStatus resultStatus) {
		this.resultStatus = resultStatus;
	}
	
}
